import JSEncrypt from 'jsencrypt/bin/jsencrypt.min'

// 密钥对生成 http://web.chacuo.net/netrsakeypair

// const publicKey = 'MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAKoR8mX0rGKLqzcWmOzbfj64K8ZIgOdH\n' +
//   'nzkXSOVOZbFu/TJhZ7rFAN+eaGkl3C4buccQd/EjEsj9ir7ijT7h96MCAwEAAQ=='

const publicKey = "MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAMQHLTAtgJM8VBwaWloIpWIxYJuaTH4b\n"+
"NjhVxZFS49zhiOXGcEqH9bpd7q0cenrZFXF5yMY9qSmkqBRf3zY589sCAwEAAQ==\n"


const privateKey = "MIIBVgIBADANBgkqhkiG9w0BAQEFAASCAUAwggE8AgEAAkEAxActMC2AkzxUHBpa\n"+
"WgilYjFgm5pMfhs2OFXFkVLj3OGI5cZwSof1ul3urRx6etkVcXnIxj2pKaSoFF/f\n"+
"Njnz2wIDAQABAkEAjzVG9/lmAyqBr/44n6nNWM0F7Odulno+xC01JpPNz+DVDb7p\n"+
'rOMwfYFmWsp3GheWGWKrSH5ggwKCvKMDvjbiEQIhAOOALWhEaiommWgX4utoER3J\n'+
'gAQ6XuF3SHyiTmzJL911AiEA3JWwLQlPKU4ZDPX0/ZHlK9j9/P4zMSFxN3AczUN6\n'+
'0g8CIEyhMSpM2SHHjKbGXPYEQLey1r8V1j3FyxHILfhwsAG9AiEAj5M6zcWOagM0\n'+
'WPRKlzV8JhMiFqbaaTMsPvpRNOWkLs8CIQDDLtbZUPqyLJCS/tAE7QIb9Ora+iB6\n'+
'XTkgfi41xmV3OA=='

// const privateKey = 'MIIBVAIBADANBgkqhkiG9w0BAQEFAASCAT4wggE6AgEAAkEAqhHyZfSsYourNxaY\n' +
//   '7Nt+PrgrxkiA50efORdI5U5lsW79MmFnusUA355oaSXcLhu5xxB38SMSyP2KvuKN\n' +
//   'PuH3owIDAQABAkAfoiLyL+Z4lf4Myxk6xUDgLaWGximj20CUf+5BKKnlrK+Ed8gA\n' +
//   'kM0HqoTt2UZwA5E2MzS4EI2gjfQhz5X28uqxAiEA3wNFxfrCZlSZHb0gn2zDpWow\n' +
//   'cSxQAgiCstxGUoOqlW8CIQDDOerGKH5OmCJ4Z21v+F25WaHYPxCFMvwxpcw99Ecv\n' +
//   'DQIgIdhDTIqD2jfYjPTY8Jj3EDGPbH2HHuffvflECt3Ek60CIQCFRlCkHpi7hthh\n' +
//   'YhovyloRYsM+IS9h/0BzlEAuO0ktMQIgSPT3aFAgJYwKpqRYKlLDVcflZFCKY7u3\n' +
//   'UP8iWi1Qw0Y='

// 加密
export function encrypt(txt) {
  const encryptor = new JSEncrypt()
  encryptor.setPublicKey(publicKey) // 设置公钥
  return encryptor.encrypt(txt) // 对数据进行加密
}

// 解密
export function decrypt(txt) {
  const encryptor = new JSEncrypt()
  encryptor.setPrivateKey(privateKey) // 设置私钥
  return encryptor.decrypt(txt) // 对数据进行解密
}

